export default function wxRequest2Curl(options: any) {
  const { url, data, header, method = 'GET', dataType = 'json' } = options;
  if (dataType !== 'json') {
    return 'not support';
  }
  const headers = Array.from(new Set(Object.keys(header || {}).reduce((prev, key) => {
    const value = header[key];
    if (value !== undefined) {
      prev.push(`-H '${key}: ${value}'`);
    }
    return prev;
  }, [`-H 'Content-Type: application/json'`] as string[])));

  const dataStr = data ? ` -d '${JSON.stringify(data)}'` : '';

  return `curl '${url}' -X ${method.toUpperCase()} ${headers.join(' ')}${dataStr}`;
}
